//
//  MSHotelDataSource.m
//  MSJD
//
//  Created by 箭军刘 on 2018/10/22.
//  Copyright © 2018年 xiangbo. All rights reserved.
//

#import "MSHotelDataSource.h"


@implementation MSHotelDataSource

+ (void)queryHotelDataWithSuccess:(void (^)(NSArray *responseInfo))success
                          failure:(void (^)(NSError *error))failure {
    NSString *requestUrl = @"/v1/index";
    CGFloat lon = [UserAccesser longitudeValue];
    CGFloat lat = [UserAccesser latitudeValue];
    NSDictionary *param = @{@"kid":@(2), @"lon":@(lon), @"lat":@(lat)};
    [MSRequestClient GET:requestUrl parameters:param responseClassType:MSFoodResponse.class success:^(id responseObject) {
        MSFoodResponse *foodResponse = (MSFoodResponse *)responseObject;
        if (success) {
            success(foodResponse.data);
        }
    } failure:^(NSError *error) {
        if (failure) {
            failure(error);
        }
    }];
}

+ (void)queryFilterListWithKind:(NSInteger)kind
                        success:(void (^)(NSDictionary *responseInfo))success
                        failure:(void (^)(NSError *error))failure {
    NSString *requestUrl = @"v1/search/factors";
    CGFloat lon = [UserAccesser longitudeValue];
    CGFloat lat = [UserAccesser latitudeValue];
    NSDictionary *param = @{@"kid":@(kind), @"lon":@(lon), @"lat":@(lat)};
//    [MSRequestClient GET:requestUrl parameters:param responseClassType:MSFilterParamData.class success:^(id responseObject) {
//        
//    } failure:^(NSError *error) {
//        
//    }];
    [MSNetworkAPI GET:requestUrl domain:API_TOPHRMING parameters:param success:^(id responseObject) {
        if (success) {
            success((NSDictionary *)responseObject);
        }
    } failure:^(NSError *error) {
        if (failure) {
            failure(error);
        }
    }];
}

+ (void)queryCityList:(void (^)(NSDictionary *responseInfo))success
              failure:(void (^)(NSError *error))failure {
    NSString *requestUrl = @"v1/sys/cities";
    CGFloat lon = [UserAccesser longitudeValue];
    CGFloat lat = [UserAccesser latitudeValue];
    NSDictionary *param = @{@"lon":@(lon), @"lat":@(lat)};
    [MSNetworkAPI GET:requestUrl domain:API_TOPHRMING parameters:param success:^(id responseObject) {
        if (success) {
            success((NSDictionary *)responseObject);
        }
    } failure:^(NSError *error) {
        if (failure) {
            failure(error);
        }
    }];
}

@end
